package com.mt.skyhoist.util;

import java.util.ArrayList;
import java.util.List;


import com.mt.skyhoist.util.bean.DeviceModel;
import com.mt.skyhoist.util.bean.MixDatasModel;
import com.mt.skyhoist.util.view.GroupView;
import com.mt.sdk.ble.MTBLEManager;
import com.mt.sdk.ble.base.MTSeriaBase;

public class GlobalVariable {
    private static GlobalVariable mGlobalVariable;

    public static GlobalVariable getinstance() {
        if (mGlobalVariable == null) {
            mGlobalVariable = new GlobalVariable();
        }
        return mGlobalVariable;
    }

    private GlobalVariable() {
    }

    private List<DeviceModel> deviceList = new ArrayList<DeviceModel>(); // 搜索到的所有设备
    private List<List<DeviceModel>> deviceGroup = new ArrayList<>();  // 对设备进行分组过的
    private List<DeviceModel> freeDeviceList = new ArrayList<DeviceModel>(); // 不是配对设备里面的设备
    private MixDatasModel mixDatas = new MixDatasModel();
    private MTBLEManager blemanger; // 蓝牙

    public List<GroupView.GroupFmtBean> groupList;
    public List<MTSeriaBase> bles = new ArrayList<>();

    public List<DeviceModel> getDeviceList() {
        return deviceList;
    }

    public void setDeviceList(List<DeviceModel> deviceList) {
        this.deviceList = deviceList;
        refreshDeviceGroup();
    }

    public MixDatasModel getMixDatas() {
        return mixDatas;
    }

    public void setMixDatas(MixDatasModel mixDatas) {
        this.mixDatas = mixDatas;
    }

    public MTBLEManager getBleManger() {
        return blemanger;
    }

    public void setBleManger(MTBLEManager blemanger) {
        this.blemanger = blemanger;
    }

    private void refreshDeviceGroup() {
        deviceGroup.clear();
        for (int i = 0; i < 250; i++) {
            List<DeviceModel> newGroup = new ArrayList<>();
            deviceGroup.add(newGroup);

			for (DeviceModel device : deviceList) {
				if (device.getGrounpId() == i) {
					newGroup.add(device);
				}
			}
        }
    }

    public List<List<DeviceModel>> getDeviceGroup() {
        return deviceGroup;
    }

	public List<DeviceModel> getFreeDeviceList() {
		return freeDeviceList;
	}

	public void setFreeDeviceList(List<DeviceModel> freeDeviceList) {
		this.freeDeviceList = freeDeviceList;
	}
}
